package com.kitchen.ui.deco
{
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.net.URLRequest;
	
	public class Wastebin extends Sprite
	{
		public var deco:Object = null;
		private var loader:Loader;
		private var bitmap:Bitmap = null;
		
		public function Wastebin()
		{
			super();
		}
		
		public function test(deco:Object):void{
			
		}
		
		public function setSource(deco:Object):void{
			this.deco = deco;
			this.loader = new Loader;
			this.loader.load(new URLRequest(deco.sUrl));
			this.loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadedHandler);
		}
		
		private function loadedHandler(event:Event):void{
			if(this.bitmap != null){
				this.removeChild(this.bitmap);
			}
			this.bitmap = Bitmap(this.loader.content);
			this.addChild(this.bitmap);
			this.loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadedHandler);
			this.loader.unload();
			this.loader = null;
		}
	}
}